﻿#if WINDOWS

namespace KinonekoSoftware.Foundation.UI.Controls
{
    public partial class ForestTextBoxBase
    {
        public static readonly DependencyPropertyKey HasTextPropertyKey;
        public static readonly DependencyProperty HasTextProperty;
        public static readonly DependencyProperty WatermarkProperty;
        public static readonly DependencyProperty CornerRadiusProperty;

        static ForestTextBoxBase()
        {
            CornerRadiusProperty = DependencyProperty.Register(
                nameof(CornerRadius),
                typeof(CornerRadius),
                typeof(ForestTextBoxBase),
                new PropertyMetadata(default(CornerRadius)));
            
            WatermarkProperty = DependencyProperty.Register(
                nameof(Watermark),
                typeof(string),
                typeof(ForestTextBoxBase),
                new PropertyMetadata(default(string)));
            
            HasTextPropertyKey = DependencyProperty.RegisterReadOnly(
                nameof(HasText),
                typeof(bool),
                typeof(ForestTextBoxBase),
                new PropertyMetadata(default(bool)));

            HasTextProperty = HasTextPropertyKey.DependencyProperty;
        }

        protected override void OnTextChanged(TextChangedEventArgs e)
        {
            HasText = !string.IsNullOrEmpty(Text);
            base.OnTextChanged(e);
        }

        public CornerRadius CornerRadius
        {
            get => (CornerRadius)GetValue(CornerRadiusProperty);
            set => SetValue(CornerRadiusProperty, value);
        }

        public string Watermark
        {
            get => (string)GetValue(WatermarkProperty);
            set => SetValue(WatermarkProperty, value);
        }

        public bool HasText
        {
            get => (bool)GetValue(HasTextProperty);
            private set => SetValue(HasTextPropertyKey, value);
        }
    }
}


#endif